package com.aceitunaproject.server.message.processor;

import com.aceitunaproject.server.AceitunaContext;
import com.aceitunaproject.server.player.Player;
import com.aceitunaproject.shared.message.Message;
import com.aceitunaproject.shared.message.concrete.ActionListRequest;
import com.aceitunaproject.shared.message.concrete.ActionRequest;

/**
 * Handles Action Request Messages, iterating through each ActionRequest on the
 * list and calling it's perform method
 * 
 * @author Federico Bergstein
 * 
 */
public class ActionListRequestProcessor implements MessageProcessor {

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void processMessage(Player player, Message message) {

		ActionListRequest actionListRequest = (ActionListRequest) message;

		//Calls the handler for each ActionRequest in the list.
		for (ActionRequest actionRequest : actionListRequest.getActions()) {

			AceitunaContext.getMessageHandler().handleObjectMessage(player,
					actionRequest);
		}
	}

}
